#! /bin/bash

if [ -n "$1" ]; then
    data_date="$1"
else
    data_date=$(date -d " -1 days" +%F)
fi

load_data_sql="LOAD DATA INPATH '/warehouse/app_logs/$data_date'
OVERWRITE INTO TABLE jtp_app_ods.ods_event_app_log PARTITION (dt = '$data_date');"

/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${load_data_sql}"